package foundamental.version1;

/**
 * Created by chenjun on 2017/12/18.
 */
public class A {

    //*************情况1：递归：死循环，堆栈溢出
    public void m1(){
        m1();
    }

    //********情况1  结束*******

    //******情况2开始:m2与m3合起来也会形成递归，死循环，堆栈溢出**********
    public void m2(){
        m3();
    }

    public  void m3(){
        m2();
    }
    //********情况2: 结束********************************




    //这里没有递归
    public void am1(){
        System.out.println("method one in a");
        new B().bm1();
    }

//这里有递归，也会有死循环。堆栈溢出
    private  int i = 0;
    public void am2(){
        i++;
        System.out.println("method two in a " + i);
        new B().bm2(this);
    }


    private  int j = 0;
    public void am3(){
        j++;
        System.out.println("method two in a " + j);
        if(j>=5) return ;

        new B().bm3(this);
    }

}
